package cn.edu.dzkd.software.controller;

import cn.edu.dzkd.software.pojo.Module;
import cn.edu.dzkd.software.pojo.User;
import cn.edu.dzkd.software.service.ModuleService;
import cn.edu.dzkd.software.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: PDJ
 * Date: 2022/07/07 17:33
 * Description:
 * Version: V1.0
 */
@RestController
@RequestMapping("/module")
public class ModuleController{
    @Resource
    private ModuleService moduleService;  // spring框架自动生成了一个mapper对象，注入到此属性中

    @RequestMapping("/selectModules")
    public Map<String, Object> selectModules(@RequestParam int page,
                                             String moduleName,
                                             String moduleVersion,
                                             String dangerlevel) {
        return moduleService.selectModules(page,moduleName,moduleVersion,dangerlevel);
    }

    @RequestMapping("/insert")
    public Map<String, Object> insertModuleJSON(@RequestBody Module module) {
        return moduleService.insertModuleJSON(module);
    }

    @RequestMapping("/delete")
    public Map<String, Object> deleteById(@RequestParam String id) {
        return moduleService.deleteById(id);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String, Object> update(@RequestBody Module module) {
        return moduleService.update(module);
    }
}

